package JAVA300.第十一章多线程;

/**
 * 测试yield
 * 在主线程中测试
 */

public class thread_11_threadState_yield1 {
    public static void main(String[] args) {
        new Thread(()->{
            for (int i=0;i<100;i++){
                System.out.println("lamda thread"+i);
            }

        }).start();

        //主线程
        for (int i=0;i<100;i++){
            if (i%20 ==0){
                Thread.yield();//主线程礼让
            }
            System.out.println("main thread"+i);

        }

    }
}

